home *** CD-ROM | disk | FTP | other *** search
- Path: hamlet.uncg.edu!b_lee2
- From: "Bin . Lee" <b_lee2@hamlet.uncg.edu>
- Newsgroups: comp.lang.c++,comp.lang.c
- Subject: Safest way to define a string
- Date: Sat, 17 Feb 1996 12:59:37 -0500
- Organization: The University of North Carolina at Greensboro
- Message-ID: <Pine.SOL.3.91.960217124454.26354A-100000@hamlet.uncg.edu>
- NNTP-Posting-Host: hamlet.uncg.edu
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
-
-
- Hi: Folks:
-
- This is a simplest question, I think many of you know the answer, please
- help me and send me a email.
-
- Question is: which is the safest way to define a string ?
-
- a. some one told me to use the following approach:
- const int STRLEN = 100;
- char strTest[STRLEN + 1];
-
- Then always use strTest[STRLEN] =0;
- This is OK, but if I have to pass a 2D array to function,
- it will looks like
-
- int TestFun( char strTest2D[][STRLEN + 1] );
- This is really awkward.
-
- If I just want to use array, is it safe to use Array class ? or string
- class ?
-
- Anyway, my real question is how to prevent memory overflow for array ?
- can I overload global subscript operation [] and unary operator * ?
-
- Thanks in advance, this is important for me, please reply me in mail.
- I do not want to miss it.
-
-
- Cheers
-
-
-